<?php

namespace app\store\model;

use think\Model;
use think\model\concern\SoftDelete;

class GroupActivity extends Model
{
    use SoftDelete;

    protected $autoWriteTimestamp = 'int';

    protected $defaultSoftDelete = 0;

    protected $schema = [
        'id' => 'int',
        'store_id' => 'int',
        'activity_title' => 'string',
        'activity_cover' => 'string',
        'start_time' => 'int',
        'end_time' => 'int',
        'is_transfer' => 'int',
        'prepayment_amount' => 'float',
        'group_num' => 'require|integer',
        'rule_content' => 'string',
        'win_num' => 'int',
        'success_rule' => 'json',
        'fail_rule' => 'json',
        'transfer_people_num' => 'int',
        'transfer_times' => 'int',
        'is_coupon' => 'int',
        'is_resell_coupon' => 'int',
        'resell_rate' => 'float',
        'is_limit_member' => 'int',
        'resell_time' => 'int',
        'status' => 'int',
        'create_time' => 'int',
        'update_time' => 'int',
        'delete_time' => 'int',
    ];

    protected $type = [
        'prepayment_amount' => 'float',
        'success_rule' => 'json',
        'fail_rule' => 'json',
    ];

    public function setStartTimeAttr($value)
    {
        return strtotime($value);
    }

    public function setEndTimeAttr($value)
    {
        return strtotime($value);
    }

    public function goods()
    {
        return $this->belongsToMany(GroupGoods::class,GroupActivityGoods::class);
    }



}